# #1.先安装一个科学计算的框架
# import numpy as np
# a=np.array([[3,2,3],[3,2,3],[3,2,3]])
# b=np.array([1,2,3])
# #奇异矩阵  点乘  转置  逆
# print(a.T)
# print(a.dot(b))
# print(np.linalg.pinv(a))
import numpy as np
from datas import datas
X=[]
Y=[]
cityMark={"吕梁":1,"太原":2}
for item in datas:
    single=[]
    #城市
    single.append(cityMark[item["city"]])
    #面积
    single.append(item["area"])
    #房间数
    single.append(item["rooms"])
    #学区房
    single.append(item["school"])
    #装修
    single.append(item["style"])
    X.append(single)
    Y.append(item["price"])
X=np.array(X)
Y=np.array(Y)

theta=np.linalg.pinv(X.T.dot(X)).dot(X.T).dot(Y)
print(theta.dot(np.array([2,100,2,1,1])))